<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="./index.css">
</head>

<body>
  <div class="container">
    <div class="items left" data-color="background: radial-gradient(#999,#cc6c0e)"><img src="./img/鸣人.png" width="100%"
        alt=""></div>
    <div class="items middle" data-color="background: radial-gradient(#999,#293242)"><img src="./img/佐助.png"
        width="100%" alt=""></div>
    <div class="items right" data-color="background: radial-gradient(#999,#bc4641)"><img src="./img/小樱.png" width="100%"
        alt=""></div>
  </div>
  <script>
    const items = document.querySelectorAll('.items')
    console.log(document.body.style.background)
    for (let i = 0; i < items.length; i++) {
      items[i].addEventListener('click', function () {
        this.classList.remove('left', 'middle', 'right')
        this.classList.add('middle')
        document.body.style = this.dataset.color
        let left = this.previousElementSibling ?? items[items.length - 1]
        left.classList.remove('left', 'middle', 'right')
        left.classList.add('left')
        let right = this.nextElementSibling ?? items[0]
        right.classList.remove('left', 'middle', 'right')
        right.classList.add('right')
      })
    }
  </script>
</body>

</html>